﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
#if NETFX_CORE
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;
#else
using System.Windows.Controls;
#endif

namespace ArchiSimple.Windows
{
    public class PlanObjectStyleSelector : StyleSelector
    {
#if NETFX_CORE
        protected override Style SelectStyleCore(object item, DependencyObject container)
#else
        public override Style SelectStyle(object item, DependencyObject container)
#endif
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null)
            {
                var name = item.GetType().Name;

                return element.FindResource(name.Substring(0, name.Length - "ViewModel".Length) + "Style") as Style;
            }

            return null;
        }
    }
}
